package pratice;


import java.io.*;

/**
 * @author feng
 * @Date 2022/1/1 19:47
 * eg:将C盘一个文本文件复制到D盘,字节流会乱码，字符流不会乱码
 */
public class Test01 {
    public static void main(String[] args) {
        String path = "D:\\IO\\1.text";
        String dest = "D:\\IO\\A\\B\\1.text";
        BufferedReader reader1 = null;
        BufferedWriter writer = null;
        int i = 0;
        try {
            FileReader reader = new FileReader(path);
            FileWriter fileWriter = new FileWriter(dest);
            reader1 = new BufferedReader(reader);
            writer = new BufferedWriter(fileWriter);
            while ((i = reader1.read()) != -1) {
                writer.write(i);
            }
            System.out.println("复制完成");
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                reader1.close();
                writer.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}
